import * as mobx from 'mobx';
import { ListStore } from './listStore';
import { WeaTools , WeaLocaleProvider} from 'ecCom';
import { WeaForm ,WeaTableNew} from 'comsMobx';
const { TableStore } = WeaTableNew;
import * as API_MONITOR from '../apis/monitor';
import isEmpty from 'lodash/isEmpty';

const getLabel = WeaLocaleProvider.getLabel;
const Base64 = WeaTools.Base64;
const observable = mobx.observable;
const action = mobx.action;
/**
 * 
 * 
 */
 
export class WFMonitorIndexStore extends ListStore {
    urlParams = {};
    searchParams = {
        createdateselect:0
    };
    @observable forceRender = 1;
    @observable switchForm = {};
    selectedRowKeys = [];
    resultFormValue = {};
    @observable leftLayoutShow = false;

    @observable btnObj = {key:'batchDelete'};

    constructor(){
        super();
        this.setUrlParams = this.setUrlParams.bind(this);
        this.loadCondition = this.loadCondition.bind(this);
        this.resetConditionValue = this.resetConditionValue.bind(this);
        this.resetCondition = this.resetCondition.bind(this);
    }

    @action
    setUrlParams(queryParams = {}){
        this.urlParams = queryParams;
        if(this.urlParams.tabTitle){
          this.title = this.urlParams.tabTitle;
        }
    }

    loadCondition(params={}){
        this.loading = true;
        this.setTitle(getLabel(385194,'流程监控'));
        if(this.urlParams.tabTitle){
          this.title = Base64.decode(decodeURIComponent(this.urlParams.tabTitle));
        }
        this.setShowSearchAd(false);
        API_MONITOR.getMonitorConditionInfo(this.urlParams).then((data)=>{
            this.loading = false;
            if("pagetitle" in data)
                this.title = data.pagetitle;
            let condition = data.conditioninfo;
            this.condition = condition;
            this.form = new WeaForm();
            this.form.initFormFields(condition);
            let monitorIndexStore = {
              condition: condition,
              form : this.form
            }
            WeaTools.ls.set("listMonitorCondition", monitorIndexStore);
        });
    }

    resetConditionValue(){
        this.clearFormFields();     //清除固定条件的form值
    } 

   

    resetCondition(){
        this.setTitle(getLabel(385194,'流程监控'));
        this.clearFormFields();
    }

}
  